﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace DeviceDebugger.Converter
{
    public class ConverterDoubleCommon : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null)
                return value;
            else
            {
                double a = default(double);
                double.TryParse(value.ToString(), out a);
                double b = default(double);
                double.TryParse(parameter.ToString(), out b);
                if (b <= 5)
                    return a * b;
                else
                    return a - b;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
